home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
MATHEMAT
/
0502.ZIP
/
CURVEFIT.DOC
< prev
next >
Wrap
Text File
|
1986-12-31
|
22KB
|
515 lines
DOCUMENTATION FILE FOR CURVEFIT
╔═══════════╦═══════════════════════════════════════════════════════╦══════════╗
║ CURVEFIT ║ Version 2.10 December 31, 1986 by Thomas S. Cox ║ CURVEFIT ║
╠═══════════╩═══════════════════════════════════════════════════════╩══════════╣
║ PURPOSE This program performs a least squares curve fit on X, Y data. ║
║ Curves for 25 equations are fitted. Equation coefficients, ║
║ Correlation Coefficient, and Best Fit are computed. For any ║
║ of the 25 equations, predictions for Y can be calculated. ║
║ ║
║ REFERENCE CURVE FITTING FOR PROGRAMMABLE CALCULATORS by William M. Kolb ║
║ Published by: IMTEC P. O. Box 1402 Bowie MD 20716 ║
║ ║
║ DISCLAIMER Although effort has been taken to insure that accurate ║
║ results are obtained when using this program, the user ║
║ assumes ALL risks. Good practice dictates that sample data ║
║ will be used before using REAL data. ║
║ ║
║ COPIES This program is placed in the PUBLIC DOMAIN and may be ║
║ freely copied. However, the author retains all commercial ║
║ rights. For a copy of latest version send a DSDD (360k) disk ║
║ and postage or, alternatively, $5.00 to the author at: ║
║ 102 Evergreen St. Easley, SC 29640. Comments are welcomed. ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ PROGRAM Compiled using Microsoft's Quick BASIC version 2.0. ║
║ ASCII source file is also supplied. ║
║ ║
║ ACCURACY: Double precision routines are used to insure ║
║ accuracy. No exponentiation routines are used. ║
║ ║
║ COMMENTS: IBM line graphics characters are used in this program. ║
║ The program was originally written for a CP/M 80 ║
║ system. ║
║ ║
║ This implementation supports positive, negative and ║
║ zero values for X and Y. 255 points are permitted. ║
║ ║
║ Latest revision uses LOCATE command extensively for ║
║ improved ease of data entry and data changes. Printer ║
║ may be used with this program, but is not required. ║
║ ║
║ For equations 2 and 9, R squared is not computed. ║
║ No formula was given in the reference source. ║
║ ║
║ Note: Latest revision will automatically DELETE ║
║ null lines that are created at the top of a ║
║ LOTUS 1-2-3 .PRN file. ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
╔═══════════╦═══════════════════════════════════════════════════════╦══════════╗
║ CURVEFIT ║ Version 2.10 December 31, 1986 by Thomas S. Cox ║ CURVEFIT ║
╠═══════════╩═══════════════════════════════════════════════════════╩══════════╣
║ M A S T E R M E N U ║
╠═══════════╦══════════╤═══════════════════════════════════════════════════════╣
║ SELECT ║ CHOICES │ BRIEF DESCRIPTION OF CHOICES ║
╠═══════════╬══════════╪═══════════════════════════════════════════════════════╣
║ [ ] ║ ENTER │ New Data (X and Y values) |LIMIT VALUES TO +/- 10,000 ║
║ [ ] ║ LOAD │ A Previously Stored Data File ║
║ [ ] ║ ADD │ Data to Values of X and Y Currently in Memory ║
║ [ ] ║ DELETE │ or CHANGE Values of X and Y Currently in Memory ║
║ [ ] ║ LIST │ X and Y Values Currently in Memory ║
║ [ ] ║ CALCULATE│ Equation Coefficients (A, B, C, and R^2) ║
║ [ ] ║ PREDICT │ Value of Y, given Value of X ║
║ [ ] ║ SHOW │ LIST of EQUATIONS Fitted Using this Program ║
║ [ ] ║ REVIEW │ Equation Coefficients (A, B, C, R^2) ║
║ [ ] ║ DISPLAY │ List of SUMS and SUMS of SQUARES ║
║ [ ] ║ STORE │ X and Y Data Points to a DISK FILE ║
║ [ ] ║ EXIT │ Leave Program and EXIT to DOS ║
╠═══════════╩══════════╧═══════════════════════════════════════════════════════╣
║ USE <UP> OR <DOWN> KEYS TO MAKE SELECTION, PRESS <ENTER>. <ESC> to EXIT ║
╚══════════════════════════════════════════════════════════════════════════════╝
The above menu is the main program menu and the choices are explained below:
explained below:
1. ENTER NEW DATA: Clears out any previously entered data to prepare
for new data entry.
2. ADD DATA POINTS: Add data to previously entered data. Must use
choice 4 (Calculate equation coefficients) to update
coefficients to reflect newly added data.
3. DELETE OR CHANGE: Self-explanatory. Can change or delete any data
points. Again, must use choice 4 to update coefficients.
4. CALCULATE COEFF: Recalculates required sums and sums of squares for
equation coefficients.
5. PREDICT Y FROM X: For the 25 equations fitted, allows entry of a range of
values for X. From this, values of Y are calculated.
6. STORE TO DISK: Stores X and Y raw data to disk. Equation coefficients
are not stored. Neither are the sums or sums of squares.
7. LOAD DATA: Writes over any date already present. Can use a Comma
Separated data file, LOTUS or SuperCalc .PRN files, or
files created by this program. Preferred data format is:
X(), Y() CR/LF to terminate line.
8. PROGRAM EXIT: EXITS to BASIC.
9. LIST DATA: Lists values of X and Y as entered.
10. LIST SUMS: Lists all sums and sums of squares.
11. EQS FITTED: Shows on the screen the equations fitted and a brief
description of the type of the equation. Because of
space limitations, shorter version in CP/M program.
12. PRT COEFFICIENTS: Prints equation coefficients (A, B, C, and Coefficient
of Determination. Also shows the Coefficient of
Determination corrected for degrees of freedom.
╔═══════════════════════════════════════════════════════════════════════════╗
║ EQUATIONS FITTED USING THIS PROGRAM ║
╠════════════════════════════════════╦══════════════════════════════════════╣
║ 1. Y=A+B*X STR. LINE ║ 2. Y=B*X LINE THRU ORG. ║
║ 3. Y=1/(A+B*X) REC. STR LINE ║ 4. Y=A+B*X+C/X LIN AND RECIP. ║
║ 5. Y=A+B/X HYPERBOLA ║ 6. Y=X/(A*X+B) RECIP HYPERBOLA ║
║ 7. Y=A+B/X+C/X*X 2ND ORD HYP ║ 8. Y=A+B*X+C*X*X PARABOLA ║
║ 9. Y=A*X+B*X*X PAR AT ORIGIN ║ 10. Y=A*X^B POWER ║
║ 11. Y=A*B^X MOD. POWER ║ 12. Y=B^(1/X) ROOT ║
║ 13. Y=A*X^(B*X) SUPER GEOMET. ║ 14. Y=A*X^(B/X) MOD GEOMETRIC ║
║ 15. Y=A*e^(B*X) EXPONENTIAL ║ 16. Y=A*e^(B/X) MOD EXPONENTIAL ║
║ 17. Y=A+B*ln(X) LOGARITHMIC ║ 18. Y=1/(A+B*ln(X)) RECIP LOG ║
║ 19. Y=A*B^X*X^C HOERL FUNCTION ║ 20. Y=A*B^(1/X)*X^C MOD HOERL ║
║ 21. Y=A*e^((X-B)/2) NORMAL ║ 22. Y=A*e^((ln(X)-B)^2/C) LOG NORMAL║
║ 23. Y=A*X^B*(1-X)^C BETA ║ 24. Y=A*(X/B)^C*e^(X/B) GAMMA ║
║ 25. Y=1/(A*(X+B)^2+C) CAUCHY ║ ║
╠════════════════════════════════════╩══════════════════════════════════════╣
║ NOTES: A. Values of X and Y may be positive, negative, or zero ║
║ B. Only 255 values of X and Y can be used. ║
╠═══════════════════════════════════════════════════════════════════════════╣
║ Press <RETURN> to continue program execution ║
╚═══════════════════════════════════════════════════════════════════════════╝
Note: Equations 19 and 24 and Equations 12 and 16 are essentially identical.
BRIEF EXPLANATION OF EQUATIONS:
1. Straight Line
2. Straight Line through the Origin
3. Reciprocal of Straight Line
4. Combined Linear and Reciprocal
5. Hyperbola
6. Reciprocal of a Hyperbola
7. Second Order Hyperbola
8. Parabola
9. Parabola Through Origin
10. Power
11. Modified Power
12. Root (Modification of Modified Power)
13. Super Geometric
14. Modified Geometric
15. Exponential
16. Modified Exponential (Similar to Root)
17. Logarithmic
18. Reciprocal of Logarithmic
19. Hoerl's Equation
20. Modified Hoerl's Equation
21. Normal Distribution (Gaussian)
22. Log Normal
23. Beta Distribution (X must be between zero and one)
24. Gamma Distribution
25. Cauchy Distribution
EDITORIAL COMMENT:
For a full explanation of the equations used in this program and some
excellent graphs showing the shapes of curves described by these equations,
highly recommend the reference source listed previously: I have no
interest in the reference source except that I have found it to be very good.
The reference source has programs specifically for the HP-41CV and includes
barcode for a program to fit 19 of the 25 equations in this program.
Again, the reference is:
CURVE FITTING FOR PROGRAMMABLE CALCULATORS
by William M. Kolb
Published by:
IMTEC P. O. Box 1402 Bowie, Maryland 20716
LISTING OF SUMS AND SUMS OF SQUARES (DEFINITION)
The array R() is used to hold these values. The contents are:
R(16)=R(16)+X(I)
R(17)=R(17)+X(I)*X(I)
R(18)=R(18)+Y(I)
R(19)=R(19)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)+(LOG(X(I)))/X(I)
REM * END OF SUMMATION LOOP *
NOTE: R(1) THROUGH R(15) ARE NOT USED
Programs revised on December 31, 1986.
FILES SUPPLIED WITH THIS PROGRAM
CURVEFIT.BAS (ASCII Source File)
CURVEFIT.EXE Executable file compiled using Microsoft's
Quick Basic Version 2.0
CURVEFIT.DOC This documentation file
EX *.* Example Data Files, also LARGESET.DAT
EXAMPLE DATA ENTRY SCREEN
╔═══════════╦═══════════════════════════════════════════════════════╦═════════╗
║ CURVEFIT ║ Version 2.10 December 31, 1986 by Thomas S. Cox ║CURVEFIT ║
╠═══════════╩═══════════════════════════════════════════════════════╩═════════╣
║ DATA ENTRY SCREEN| Enter (S) for X or Y to terminate Data Entry ║
╠═════╦═════════╦═════════╦═════╦═════════╦═════════╦═════╦═════════╦═════════╣
║ PT #║ X VALUE ║ Y VALUE ║ PT #║ X VALUE ║ Y VALUE ║ PT #║ X VALUE ║ Y VALUE ║
╠═════╬═════════╬═════════╬═════╬═════════╬═════════╬═════╬═════════╬═════════╣
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ║ ║ ║ ║
╠═════╩══════╦══╩════════╦╩═════╩╦════════╩════╦════╩══╦══╩═════════╩═════════╣
║ ENTER DATA ║PT # 1 ║X VALUE║ ? ░░░░░░░░ ║Y VALUE║ ║
╚════════════╩═══════════╩═══════╩═════════════╩═══════╩══════════════════════╝
EXAMPLE DATA CORRECTION SCREEN
╔═══════════╦═══════════════════════════════════════════════════════╦═════════╗
║ CURVEFIT ║ Version 2.10 December 31, 1986 by Thomas S. Cox ║CURVEFIT ║
╠═══════════╩═══════════════════════════════════════════════════════╩═════════╣
║ DATA CORRECTION| Enter 'D' to DELETE, 'S' to STOP ║
╠═════╦═════════╦═════════╦═════╦═════════╦═════════╦═════╦═════════╦═════════╣
║ PT #║ X VALUE ║ Y VALUE ║ PT #║ X VALUE ║ Y VALUE ║ PT #║ X VALUE ║ Y VALUE ║
╠═════╬═════════╬═════════╬═════╬═════════╬═════════╬═════╬═════════╬═════════╣
║ 85║901 ║122 ║ 99║13 ║26 ║ 113║15 ║16 ║
║ 86║202 ║403 ║ 100║12 ║13 ║ 114║14 ║16 ║
║ 87║202 ║304 ║ 101║14 ║15 ║ 73║22 ║25 ║
║ 88║202 ║3.5 ║ 102║14 ║15 ║ 74║21 ║24 ║
║ 89║302 ║225 ║ 103║14 ║15 ║ 75║13 ║21 ║
║ 90║302 ║103 ║ 104║14 ║16 ║ 76║22 ║23 ║
║ 91║115 ║159 ║ 105║14 ║16 ║ 77║21 ║21 ║
║ 92║100 ║149 ║ 106║14 ║16 ║ 78║23 ║25 ║
║ 93║101 ║125 ║ 107║14 ║16 ║ 79║24 ║26 ║
║ 94║101 ║125 ║ 108║14 ║16 ║ 80║12 ║14 ║
║ 95║101 ║125 ║ 109║14 ║16 ║ 81║14 ║16 ║
║ 96║105 ║129 ║ 110║12 ║14 ║ 82║12 ║15 ║
║ 97║10 ║12 ║ 111║15 ║14 ║ 83║98 ║110 ║
║ 98║10 ║12 ║ 112║14 ║15.6 ║ 84║92 ║11 ║
╠═════╩══════╦══╩════════╦╩═════╩╦════════╩════╦════╩══╦══╩═════════╩═════════╣
║ ENTER DATA ║PT # ? ║X VALUE║ ║Y VALUE║ ║
╚════════════╩═══════════╩═══════╩═════════════╩═══════╩══════════════════════╝
EXAMPLE DATA LISTING SCREEN
╔═══════════╦═══════════════════════════════════════════════════════╦═════════╗
║ CURVEFIT ║ DATA LIST OF X AND Y VALUES (X$,Y$) NOW IN MEMORY ║CURVEFIT ║
╠═════╦═════╩═══╦═════════╦═════╦═════════╦═════════╦═════╦═════════╬═════════╣
║ PT #║ X VALUE ║ Y VALUE ║ PT #║ X VALUE ║ Y VALUE ║ PT #║ X VALUE ║ Y VALUE ║
╠═════╬═════════╬═════════╬═════╬═════════╬═════════╬═════╬═════════╬═════════╣
║ 1║2 ║3 ║ 19║23 ║24 ║ 37║45 ║51 ║
║ 2║3 ║4 ║ 20║24 ║25 ║ 38║65 ║69 ║
║ 3║4 ║5 ║ 21║26 ║27 ║ 39║66 ║67 ║
║ 4║5 ║6 ║ 22║27 ║28 ║ 40║66 ║68 ║
║ 5║6 ║7 ║ 23║28 ║29 ║ 41║98 ║120 ║
║ 6║7 ║8 ║ 24║29 ║32 ║ 42║32 ║40 ║
║ 7║8 ║9 ║ 25║33 ║34 ║ 43║101 ║102 ║
║ 8║9 ║10 ║ 26║34 ║35 ║ 44║102 ║103 ║
║ 9║11 ║12 ║ 27║35 ║36 ║ 45║102 ║104 ║
║ 10║12 ║13 ║ 28║36 ║37 ║ 46║102 ║105 ║
║ 11║13 ║14 ║ 29║37 ║38 ║ 47║102 ║105 ║
║ 12║14 ║15 ║ 30║38 ║41 ║ 48║102 ║103 ║
║ 13║15 ║16 ║ 31║42 ║44 ║ 49║105 ║119 ║
║ 14║16 ║17 ║ 32║43 ║44 ║ 50║120 ║129 ║
║ 15║17 ║18 ║ 33║45 ║47 ║ 51║121 ║125 ║
║ 16║18 ║19 ║ 34║48 ║53 ║ 52║121 ║125 ║
║ 17║20 ║21 ║ 35║53 ║56 ║ 53║121 ║135 ║
║ 18║22 ║23 ║ 36║56 ║59 ║ 54║135 ║169 ║
╚═════╩═════════╩═════════╩═════╩═════════╩═════════╩═════╩═════════╩═════════╝
MISCELLANEOUS NOTES:
1. LISTING DATA Will show 54 data points per screen. To view
next 54 data points, press <ENTER>.
2. ADD DATA When reading data into screen array, program
will show latest, that is the highest numbered,
set of 42 data points. Prompt for PT# will be
for one data point higher than currently existing
number of data points. Entering 'S' for X or Y
will terminate additions.
3. DELETE DATA Screen will look similar to ADDITION screen.
IMPORTANT NOTE: If 'S' is stored as a DATAPOINT,
that point will be last one
recognized, even if there is more
valid data. Always exit from
this routine by entering 'S' for a
data point number higher than any
valid data.
To change data, just enter point number and the new
values for X and Y.
4. Program will read a file that has blank lines in it such as might
be created with a word-processing program. See for example the file
DUMMY.DAT on the distribution disk. This program will insert 'DEL'
entries at the appropriate places and then delete them. Data file
will automatically be condensed to fill slots occupied by 'DEL'.
5. Please address any comments, suggestions, etc. to the author at:
Thomas S. Cox
102 Evergreen Street
Easley, SC 29640
6. One last comment. Just because the compiled program shows properly
on the screen, there is no guarantee that the source code used with
interpreted Basic will work equally well. I do not know why.
Program and Documentation File last updated 12/31/86
===========end of document file==========